﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.ServiceModel;

namespace Tesla.Web
{
   
    public class GADNChannelFactoryProvider 
    {
        
        public static ChannelFactory<T> CreateChannelFactory<T>()
        {
            ChannelFactory<T> _channelFactory = null;
            try
            {
                _channelFactory = new ChannelFactory<T>("");
                return _channelFactory;
            }
            catch (TimeoutException exception)
            {
                if (_channelFactory.State == CommunicationState.Opened)
                    _channelFactory.Close();
                if (_channelFactory.State == CommunicationState.Faulted)
                    _channelFactory.Abort();
                throw exception;
            }
            catch (CommunicationException exception)
            {
                if (_channelFactory.State == CommunicationState.Opened)
                    _channelFactory.Close();
                if (_channelFactory.State == CommunicationState.Faulted)
                    _channelFactory.Abort();
                throw exception;
            }
            catch (Exception exception)
            {
                throw exception;
            }
        }


    }

}
